import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import java.util.*;

public class retroWorld extends World
{
    
    MidiPlayer music;
    WavPlayer soundBite;
    WavPlayer musicWAV;
    
    //coin c;
    Simon simon;
    Health health;
    coin monedas;
    GameOver gameover;
    GameOver1 gameover1;
    Title title;
    StartButton startButton;
    InstructionsButton instructionsButton;
    Lolzturtle tortugon;
    CreditsButton creditsButton;
    CreditsScreen creditsScreen;
    PlayAgainButton playAgainButton;
        
    InstructionScreen instructionScreen;
    BackButton backButton;
    
    public static final int worldWidth = 600;
    public static final int worldHeight = 432;
    public static final int middle = worldWidth/2;
    private static final int scrollSpeed = 3;
    private static final int NUM_ENEMIES_FIRST_LEVEL = 21;
    private static final int NUM_ENEMIES_SECOND_LEVEL = 26;
    private static final int NUM_ENEMIES_FINAL_LEVEL = 32;
    
    private  GreenfootImage bg;
    private  GreenfootImage mask;
    private  GreenfootImage tempbg;
    boolean simonAlive = false;
    boolean isInstructionScreen = false;
    boolean isCreditsScreen = false;
    boolean isGameOverScreen = false;
   
   // private GreenfootImage level2;
   // private GreenfootImage level2Mask;
    
    private int scrollPos;
    private static int scrollEnd;
    
    private Color ground = Color.BLACK;
    private Color endLevel = Color.GREEN;
    private Color stairsRight = Color.RED;
    private Color stairsLeft = Color.BLUE;
    
    private Enemy enemyQueue[];

    private int index; //Index for current queued enemy
    
    private int level;

    /**
     * Constructor for retroWorld, instantiates all the objects.
     * 
     */
    public retroWorld()
    {    super(worldWidth, worldHeight, 1); 
        // Create a new world with 20x20 cells with a cell size of 10x10 pixels.
       reset();
       Greenfoot.start();
    } 
    
    
    
    public void reset(){
        
        // Create a new world with 20x20 cells with a cell size of 10x10 pixels.
        
      
        index=0;
        level=0;
         
        //music = new MidiPlayer("daytime.mid");
        //soundBite = new WavPlayer();
        //musicWAV=new WavPlayer();
            
        // Instantiate our actors
        //c = new coin();
        health = new Health();
        monedas = new coin();
        title = new Title();
        startButton = new StartButton();
        instructionsButton = new InstructionsButton();
        tortugon = new Lolzturtle();
        creditsButton = new CreditsButton();
        instructionScreen = new InstructionScreen();
        backButton = new BackButton();
        creditsScreen = new CreditsScreen();
        playAgainButton = new PlayAgainButton();
        
        bg = new GreenfootImage("mapa1.png");
        mask = new GreenfootImage("mascara1.png");
        
        tempbg = new GreenfootImage(worldWidth, worldHeight);
        simon = new Simon();
        simonAlive = false;
        
        scrollEnd= -bg.getWidth() + worldWidth;
        
        // Start the title screen when Run is pressed
        startTitleScreen();   
        
        
        
    }
    
    /** Displays the title screen and all the buttons
     * 
     */
    private void startTitleScreen()
    {
        addObject(title, 300, 216);
        addObject(tortugon, 280, 300);
        addObject(startButton, 478, 296);
        addObject(instructionsButton, 474, 385);
        addObject(creditsButton, 105, 383);
        
    }
    
    /** Display our instruction screen when instructionsButton is pressed
     * 
     */
    private void displayInstructionScreen()
    {
        removeObject(tortugon);
        removeObject(title);
        removeObject(startButton);
        removeObject(instructionsButton);
        removeObject(creditsButton);
        addObject(instructionScreen, 300, 216);
        addObject(backButton, 507, 390);
    }
  
    /** Display our credits screen when creditsButton is pressed
     * 
     */
    private void displayCreditsScreen()
    {
        removeObject(tortugon);
        removeObject(title);
        removeObject(startButton);
        removeObject(instructionsButton);
        removeObject(creditsButton);
        addObject(creditsScreen, 300, 216);
        addObject(backButton, 301, 393);
    }
    
    /** Start the first level when the startButton is pressed.
     * 
     */
    private void startFirstLevel()
    {
        simonAlive = true;
        removeObject(tortugon);
        removeObject(title);
        removeObject(startButton);
        removeObject(instructionsButton);
        removeObject(creditsButton);
        level = 1;
        
        loadImage();
        addObject(simon, 150, 50);
        
        scrollPos = 0;
        scrollEnd = -bg.getWidth() + worldWidth;
        enemyQueue = new Enemy[NUM_ENEMIES_FIRST_LEVEL]; //Zombie Type 1, Werewolf 2, SeekingEye 3
       
        generateEnemiesFirstLevel();
      
        addObject(health, 100, 25);
        addObject(monedas, 300, 25);
        //addObject(c, 100, 50);
        
        //soundBite.open("chew05.wav");     
      
        //soundBite.setLoops(1);
        //soundBite.play();
        Greenfoot.delay(220);
        //music.play();
    }
    
    
    /** Start the second level
     * 
     */
    private void startSecondLevel()
    {
       
        simon.dead();
        removeObject(simon);
        removeObject(health);
        level=2; 
        
        index=0;
        scrollPos=10;
        
        bg = new GreenfootImage("mapa2.png");
        mask = new GreenfootImage("mascara2.png");
        scrollEnd = -bg.getWidth() + worldWidth;
        
        scroll(1);
        
        simon=new Simon();
         
        health = new Health();
        //monedas = new coin();
        
        enemyQueue = new Enemy[NUM_ENEMIES_SECOND_LEVEL];
     
        generateEnemiesSecondLevel();
        
         
        addObject(health, 100, 25);
        addObject(monedas, 300, 25);
        addObject(simon, 150, 50);
        /*
        music.stop();
        music.load("smb1-Theme.mid");
        music.play();
        
        soundBite.open("getsome.wav");
        soundBite.setLoops(1);
        soundBite.play();*/
    }
    
    /** Start our boss level
     * 
     */
    public void startFinalLevel()
    {
        simon.dead();
        removeObject(simon);
        removeObject(health);
    
        level=3; 
       
        index=0;
        scrollPos=10;
        
        bg = new GreenfootImage("mapa3.png");
        mask = new GreenfootImage("mascara3.png");
        scrollEnd = -bg.getWidth() + worldWidth;
        
        scroll(1);
        
        simon=new Simon(); 
        health = new Health();
        //monedas = new coin();
      
        enemyQueue = new Enemy[NUM_ENEMIES_FINAL_LEVEL];
     
        generateEnemiesFinalLevel();
          
        addObject(health, 100, 25);
        addObject(monedas, 300, 25);
        addObject(simon, 150, 50);
        /*
        music.stop();
        music.load("z2ow.mid");
        music.play();
        
        soundBite.open("ripem.wav");
        soundBite.setLoops(1);
        soundBite.play();*/
    }
    
    /** Our act method that checks and changes the display on the title screen or whether to load
     *  the next level when we reach the end of the current level
     */
    public void act()
    {   
        // Are we actually playing the game yet
        if(simonAlive){
        
            switch(level){
                case 1:
                    //spawnSecondLevel();
                    spawnFirstLevel();
                    break;
            
                 case 2:
                    spawnSecondLevel();
                    break;
             
                 case 3:
                    spawnFinalLevel();
                    break;
            
                 default:
                    break;
            
            }
            
            if (simonAlive && level==1 && endLevel.equals(mask.getColorAt(simon.getX() - scrollPos, simon.getY()))){
                startSecondLevel();
                return;
            }
            
            if (simonAlive && level==2 && endLevel.equals(mask.getColorAt(simon.getX() - scrollPos, simon.getY()))){
                startFinalLevel();
                return; 
            }
            
            if (simonAlive && level==3 && endLevel.equals(mask.getColorAt(simon.getX() - scrollPos, simon.getY()))){
                simonAlive = false;
                gameOver();
                return; 
            }
           
            //If statements to handle death by no hit points or falling into a hole
            if(health.getHitPoints() == 0){
                simonAlive=false;
                gameOver();
                return;
            }
           
            if (simon.getY() > worldHeight - 40){
                simonAlive = false;
                gameOver();
                return;
            }
        
        
        }//end if simon alive
        
        // Else we are at the title screen or game over screen
        else {
           if(level == 0 && isInstructionScreen == false && isCreditsScreen == false)
                startTitleScreen();
           
            if(level == 0 && Greenfoot.mousePressed(startButton))
            {
                startFirstLevel();
            }
                
            if(level == 0 && Greenfoot.mousePressed(instructionsButton)){
                displayInstructionScreen();
                isInstructionScreen = true;
            }
            
            if(level == 0 && Greenfoot.mousePressed(creditsButton)){
                displayCreditsScreen();
                isCreditsScreen = true;
            }
                
            if(level == 0 && Greenfoot.mousePressed(backButton) && isInstructionScreen == true)
            {
                removeObject(instructionScreen);
                removeObject(backButton);
                startTitleScreen();
                isInstructionScreen = false;
            }
            
            if(level == 0 && Greenfoot.mousePressed(backButton) && isCreditsScreen == true)
            {
                removeObject(creditsScreen);
                removeObject(backButton);
                startTitleScreen();
                isCreditsScreen = false;
            }
        }
        
        // HERE IS WHERE PROBLEM IS TO DELETE ALL OF THE STUFF FROM WORLD
        if(isGameOverScreen == true && Greenfoot.mousePressed(playAgainButton))
        {
               
             
                isGameOverScreen = false;
            
                List l=getObjects(Zombie.class);
                if(!l.isEmpty())
                for(int i=0;i<l.size();i++){
                  Zombie z= (Zombie) l.get(i);
                  z.removeFromWorld();
                    
                }
                
                l=getObjects(Werewolf.class);
                if(!l.isEmpty())
                for(int i=0;i<l.size();i++){
                  Werewolf w= (Werewolf) l.get(i);
                  w.removeFromWorld();
                    
                }
                
               
                
                l=getObjects(Goomba.class);
                if(!l.isEmpty())
                for(int i=0;i<l.size();i++){
                  Goomba g = (Goomba) l.get(i);
                  g.removeFromWorld();
                    
                }
                
                l=getObjects(Turtle.class);
                if(!l.isEmpty())
                for(int i=0;i<l.size();i++){
                  Turtle t = (Turtle) l.get(i);
                  t.removeFromWorld();
                    
                }
                
                
                    
                removeObjects(getObjects(null));    
                reset();
        }       

    }
    
    /** Scroll the world image when Simon is in the center of the world
     * 
     */
    public boolean scrollWorld(int d)
    {
        if (d > 0 && scrollPos >= scrollEnd)
        {
     
            scroll(scrollSpeed);
            simon.cycleRight(scrollPos);
          
            return true;
        }
        else
            return false;
    }
    
    /** Update the scroll position relative to the background image width
     * 
     */
    private void setScrollPos(int x)
    {
        scrollPos -= x;
    }
    
    /** Load up the world image for initial use
     * 
     */
    private void loadImage()
    {
        tempbg.drawImage(bg, scrollPos, 0);
        setBackground(tempbg);
    }
    
    /** Scroll the world and update scroll position
     * 
     */
    private void scroll(int x)
    {
        tempbg.drawImage(bg, scrollPos, 0);
        setBackground(tempbg);
        setScrollPos(x);
    }

    /** Function to check if our Actor is on the ground
     * 
     */
    public boolean isGround(int xPos, int yPos)
    {
        if (xPos < 0 || xPos > worldWidth || 
            yPos < 0 || yPos > worldHeight)
            return false;
            
        if (ground.equals(mask.getColorAt(xPos - scrollPos, yPos)))
            return true;
        else
            return false;
    }

    /** Function to check if our Actor is on the Stairs
     * 
     */
    public boolean isStairs(int xPos, int yPos)
    {
        if (xPos < 0 || xPos > worldWidth || 
            yPos < 0 || yPos > worldHeight)
            return false;
            
        if (stairsRight.equals(mask.getColorAt(xPos - scrollPos, yPos)) ||  stairsLeft.equals(mask.getColorAt(xPos - scrollPos, yPos)))
            return true;
    
        return false;
    }
    
    /** Return 1 if our Actor is on the stairs that face right, -1 otherwise
     * 
     */
    public int getStairDirection(int xPos, int yPos)
    {
    if (stairsRight.equals(mask.getColorAt(xPos - scrollPos, yPos)))
            return 1;
        else
            return -1;
    }
    
    /** Return reference to simon to use in enemy classes
     * 
     */
    public Simon getSimon()
    {
        return simon;
    }
    
    /** Return regerence to health bar
     * 
     */
    public Health getHealth()
    {
        return health;
    }
    
    public coin getcoin()
    {
        return monedas;
    }
    
    /** Return true if our Actor is not at either edge of the background image
     * 
     */
    public boolean canScrollWorld(int d)
    {
        if (d > 0 && scrollPos >= scrollEnd)
            return true;
        else
            return false;
    }
    
    /** Spawn enemies for the first (Castlevania) level out of the Enemy Queue
     * 
     */
    private void spawnFirstLevel()
    {
        if (index == NUM_ENEMIES_FIRST_LEVEL)
            return;
        
        if (Math.abs((enemyQueue[index].getPos() - scrollPos)) < 10)
            {
                switch(enemyQueue[index].getType())
                {
                    case 1:
                        Zombie z = new Zombie();
                        addObject(z, worldWidth, 50);
                        break;
                    
                    case 2:
                        Werewolf w = new Werewolf();
                        addObject(w, worldWidth, 50);
                        break;
                        
                    case 3:
                        Goomba g = new Goomba();
                        addObject(g, worldWidth, 25);
                        break;
                }
                
                index++;
            }
    }
    
    /** Queue up Enemies for the first (Castlevania) level for spawning
     * 
     */
    private void generateEnemiesFirstLevel()
    {
        int a=0;
        //Fill enemy queue
        for (int i = 0; i < NUM_ENEMIES_FIRST_LEVEL; i++)
        {
            Enemy e = new Enemy();
            enemyQueue[i] = e;
        }
        
         //Hard code enemy spawn locations and types
         enemyQueue[0].setType(1); //First Zombie
         enemyQueue[0].setPos(-400);
        
         //enemyQueue[a].setType(5); //Second Zombie
         //enemyQueue[a++].setPos(-400);
        
         enemyQueue[a].setType(1); //Third Zombie
         enemyQueue[a].setPos(-500);
        
         //enemyQueue[a].setType(3); //First SeekingEye
         //enemyQueue[a++].setPos(-1000);
         
         enemyQueue[a].setType(2); //First Werewolf
         enemyQueue[a++].setPos(-1400);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-1700);
        
         enemyQueue[a].setType(2); //second Werewolf
         enemyQueue[a++].setPos(-2300);
        
         enemyQueue[a].setType(2); //third Werewolf
         enemyQueue[a++].setPos(-2600);
        
         enemyQueue[a].setType(1); //4th Zombie
         enemyQueue[a++].setPos(-2900);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-3000);
        
         //enemyQueue[a].setType(1); //5th Zombie
         //enemyQueue[a++].setPos(-3200);
        
         enemyQueue[a].setType(3); //second SeekingEye
         enemyQueue[a++].setPos(-3200);
        
         enemyQueue[a].setType(1); //5th Zombie
         enemyQueue[a++].setPos(-3400);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-3600);
        
         enemyQueue[a].setType(2); //4th Werewolf
         enemyQueue[a++].setPos(-3800);
        
         enemyQueue[a].setType(3); //third SeekingEye
         enemyQueue[a++].setPos(-4000);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-4500);
        
         enemyQueue[a].setType(1); //6th Zombie
         enemyQueue[a++].setPos(-4600);
        
         enemyQueue[a].setType(2); //5th Werewolf
         enemyQueue[a++].setPos(-4700);
        
         enemyQueue[a].setType(1); //7th Zombie
         enemyQueue[a++].setPos(-4800);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-5000);
        
         enemyQueue[a].setType(3); //4th SeekingEye
         enemyQueue[a++].setPos(-5900);
        
         enemyQueue[a].setType(2); //6th Werewolf
         enemyQueue[a++].setPos(-6400);
         
         enemyQueue[a].setType(3);
         enemyQueue[a++].setPos(-6000);
        
         enemyQueue[a].setType(2); //7th Werewolf
         enemyQueue[a++].setPos(-7300);
        
         //enemyQueue[a].setType(3); //5th SeekingEye
         //enemyQueue[a].setPos(-7800);
    }
    
    /** Spawn enemies for the Second Level (Super Mario Bros.) out of the Enemy Queue
     * 
     */
    private void spawnSecondLevel()
    {   
        
        if (index == NUM_ENEMIES_SECOND_LEVEL)
            return;
        
        if (Math.abs((enemyQueue[index].getPos() - scrollPos)) < 10)
            {
                switch(enemyQueue[index].getType())
                {
                    case 0:
                        Zombie z2 = new Zombie();
                        addObject(z2, (worldWidth - 10), 50);
                        break;
                    case 1:
                        Werewolf w2 = new Werewolf();
                        addObject(w2, (worldWidth - 10), 50);
                        break;
                    case 2:
                        Turtle t = new Turtle();
                        addObject(t, worldWidth, 50);
                        break;
                    case 3:
                        Goomba g2 = new Goomba();
                        addObject(g2, (worldWidth - 10), 50);
                        break;
                }
                
                index++;
            }
    }
    
    /** Queue up enemies for the Second (Super Mario Bros.) level for spawning
     * 
     */
    private void generateEnemiesSecondLevel()
    {
        int j=0;
    
        //Fill enemy queue
        for (int i = 0; i < NUM_ENEMIES_SECOND_LEVEL; i++)
        {
            Enemy e = new Enemy();
            enemyQueue[i] = e;
        }
        
      
        //Hard code enemy spawn locations and types
        //Exploding ship
        enemyQueue[j].setType(1);
        enemyQueue[j++].setPos(-335);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-400);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-550); 
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-800);
        
        enemyQueue[j].setType(1);
        enemyQueue[j++].setPos(-950);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-1100);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-1300);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-1550);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-1550);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-1850);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-1950);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-2000);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-2250);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-2400);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-2600);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-2850);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-3150);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-3250);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-3400);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-3650);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-3800);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-3900);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-5100);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-5200);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j].setPos(-5250);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-5300);
    }
    
    /** Spawn enemies for the Final (Zelda II) level from the Enemy Queue
     * 
     */
    private void spawnFinalLevel()
    {
        if (index == NUM_ENEMIES_FINAL_LEVEL)
            return;
        
        if (Math.abs((enemyQueue[index].getPos() - scrollPos)) < 10)
            {
                switch(enemyQueue[index].getType())
                {
                    case 0:
                        Zombie z2 = new Zombie();
                        addObject(z2, (worldWidth - 10), 50);
                        break;
                    case 1:
                        Werewolf w2 = new Werewolf();
                        addObject(w2, (worldWidth - 10), 50);
                        break;
                    case 2:
                        Turtle t = new Turtle();
                        addObject(t, worldWidth, 50);
                        break;
                    case 3:
                        Goomba g2 = new Goomba();
                        addObject(g2, (worldWidth - 10), 50);
                        break; 
                    case 5:
                        Bullet b = new Bullet();
                        addObject(b, worldWidth, worldHeight-150);
                        break;
                }
                index++;
            }        
    }
    
    /** Queue up enemies for the Final (Zelda II) level for spawning
     * 
     */
    private void generateEnemiesFinalLevel()
    {
        int j=0;
        //Fill enemy queue
        for (int i = 0; i < NUM_ENEMIES_FINAL_LEVEL; i++)
        {
            Enemy e = new Enemy();
            enemyQueue[i] = e;
        }        
      
        //Hard code enemy spawn locations and types
        //Exploding ship
        
        enemyQueue[j].setType(1);
        enemyQueue[j++].setPos(-335);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-550); 
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-800);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-900);
        
        enemyQueue[j].setType(1);
        enemyQueue[j++].setPos(-950);
        
        enemyQueue[j].setType(5);
        enemyQueue[j++].setPos(-950);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-1100);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-1300);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-1550);
        
        enemyQueue[j].setType(5); 
        enemyQueue[j++].setPos(-1550);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-1550);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-1850);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-1950);
        
        enemyQueue[j].setType(5); 
        enemyQueue[j++].setPos(-1950);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-2000);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-2250);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-2400);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-2600);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-2850);
        
        enemyQueue[j].setType(5); 
        enemyQueue[j++].setPos(-2850);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-3150);
        
        enemyQueue[j].setType(5); 
        enemyQueue[j++].setPos(-3250);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-3300);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j++].setPos(-3340);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-3550);
        
        enemyQueue[j].setType(3); 
        enemyQueue[j++].setPos(-3800);
        
        enemyQueue[j].setType(5); 
        enemyQueue[j++].setPos(-3850);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-3900);
        
        enemyQueue[j].setType(2); 
        enemyQueue[j++].setPos(-3900);
        
        enemyQueue[j].setType(1); 
        enemyQueue[j++].setPos(-4200);
        
        enemyQueue[j].setType(3);
        enemyQueue[j++].setPos(-4300);
        
        enemyQueue[j].setType(0); 
        enemyQueue[j].setPos(-4350);
    }
    
    /** Add game over screen
     * 
     */
    public void gameOver(){       
    
        gameover = new GameOver();
        //music.stop();
        //soundBite.open("GameOver.wav");
        //soundBite.setLoops(1);
        //soundBite.play();
        addObject(gameover,300,220);
        simon.dead();
        isGameOverScreen = true;
        addObject(playAgainButton, 304, 309);
    }    

    public void gameOver1(){       
    
        gameover1 = new GameOver1();
        //music.stop();
        //soundBite.open("GameOver.wav");
        //soundBite.setLoops(1);
        //soundBite.play();
        addObject(gameover1,300,220);
        simon.dead();
        isGameOverScreen = true;
        addObject(playAgainButton, 304, 309);
    }  
    
    /** Play Chris Hansen soundbites and theme song for final battle
     * 
     */
    public void chrisSounds(){    
        /*music.stop();
        
        soundBite.open("chris.wav"); //"I'm Chris Hansen with dateline NBC" Goes here
        soundBite.setLoops(-1);
        soundBite.play();
 
        musicWAV.open("girls.wav"); //2 girls 1 cup theme
        musicWAV.setLoops(-1);
        musicWAV.play();*/
    }
    
    /** Return the current Scroll Position value
     * 
     */
    public int getScrollPos()
    {
        return scrollPos;
    }
    
    /** Return the current Level number
     * 
     */
    public int getLevel()
    {
        return level;
    }

    public void started()
    {

    }
    
    public void stopped()
    {
        /*
        music.stop();
        musicWAV.stop();
        soundBite.stop();     
        // music.close();
        */
    }  
}